
//频道
angular.module('mamApp').factory('ChannelManager', ['$http','api','paramsManager', function ($http,api,paramsManager) {
    var ChannelManager = {


        /**
         * 所有一级频道列表
         * @param params
         * @returns
         */

        categoriesAll: function () {
            return $http.get(api+'/admin/tags/categories').then(function (result) {
                return result;
            });
        }, 
        /**
         * 二级频道
         * @param params
         * @returns
         */

        channelByCategoriyId: function (categoryId) {
            return $http.get(api+'/admin/tags/channels/'+categoryId).then(function (result) {
                return result;
            });
        },
        /**
         * 一级频道列表
         * @param params
         * @returns
         */

        categoriesList: function (params) {
            return $http.get(api+'/admin/categorys/'+paramsManager.params(params)).then(function (result) {
                return result;
            });
        },
        /**
         * 一级频道详情
         * @param params
         * @returns result
         */
        categoryDetail: function (categoryId) {
            return $http.get(api+'/admin/category/'+categoryId).then(function (result) {
                return result;
            });
        },
        /**
         * 一级频道添加
         * @param params
         * @returns result
         */
        categoryAdd: function (params) {
            return $http.post(api+'/admin/category',params).then(function (result) {
                return result;
            });
        },
        /**
         * 一级频道修改
         * @param params
         * @returns result
         */
        categoryEdit: function (categoryId,params) {
            return $http.put(api+'/admin/category/'+categoryId,params).then(function (result) {
                return result;
            });
        },
        /**
         * 一级频道状态修改
         * @param params
         * @returns result
         */
        categoryStatusChange: function (categoryId,params) {
            return $http.put(api+'/admin/category/status/'+categoryId,params).then(function (result) {
                return result;
            });
        },
        /**
         * 一级频道删除
         * @param params
         * @returns result
         */
        categoryDelete: function (categoryId) {
            return $http.delete(api+'/admin/category/'+categoryId).then(function (result) {
                return result;
            });
        },
        /**
         * 检查一级频道是否存在
         * @param params
         * @returns result
         */
        categoryCkeck: function (params) {
            return $http.post(api+'/admin/category/checkCategory',params).then(function (result) {
                return result;
            });
        },
        /**
         * 二级频道列表（节目审核）
         * @param params
         * @returns result
         */
        channelList: function (params) {
            return $http.get(api+'/admin/category/channels/'+paramsManager.params(params)).then(function (result) {
                return result;
            });
        },
        /**
         * 二级频道列表
         * @param params
         * @returns result
         */
        channelsList: function (params,query) {
            return $http.get(api+'/admin/category/channels/'+paramsManager.params(params)+paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         * 二级频道状态修改
         * @param params
         * @returns result
         */
        channelsStatusChange: function (channelId,params) {
            return $http.put(api+'/admin/channel/status/'+channelId,params).then(function (result) {
                return result;
            });
        },
        /**
         * 二级频道删除
         * @param params
         * @returns result
         */
        channelsDelete: function (channelId) {
            return $http.delete(api+'/admin/channel/'+channelId).then(function (result) {
                return result;
            });
        },
        /**
         * 检查二级频道是否存在
         * @param params
         * @returns result
         */
        channelsCkeck: function (params) {
            return $http.post(api+'/admin/channel/checkChannel',params).then(function (result) {
                return result;
            });
        },
        /**
         * 二级频道添加
         * @param params
         * @returns result
         */
        channelsAdd: function (params) {
            return $http.post(api+'/admin/channel',params).then(function (result) {
                return result;
            });
        },
        /**
         * 二级频道修改
         * @param params
         * @returns result
         */
        channelsEdit: function (channelId,params) {
            return $http.put(api+'/admin/channel/'+channelId,params).then(function (result) {
                return result;
            });
        },

    };

    return ChannelManager;
}]);
